package com.example.myapplication;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

public class MyCircle extends View {
    private Paint paint;
    public MyCircle(Context context, AttributeSet attrs) {
        super(context, attrs);
        paint=new Paint();
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.STROKE);
    }
    private int porgress=88;
    @Override
    protected  void onDraw(Canvas canvas){
        super.onDraw(canvas);
        paint.setColor(Color.BLUE);
        paint.setStrokeWidth(2);
        paint.setTextSize(60);
        canvas.drawText("运动消耗",180,340,paint);
        paint.setTextSize(80);
        canvas.drawText(""+porgress+"%",230,460,paint);
        paint.setStrokeWidth(17);
        canvas.drawArc(100,200,500,600,270,360*porgress/100,false,paint);
    }

    public void setPorgress(int porgress){
        this.porgress=porgress;
        invalidate();
    }
}
